#ifndef UDP_H
#define UDP_H

#include <QObject>
#include <QUdpSocket>
#include <QMap>

class Udp : public QObject
{
    Q_OBJECT
public:
    explicit Udp(QObject *parent = nullptr);
    ~Udp();

    void openAllPort();
    void sendData(const QString &ip, const quint16& port, const QByteArray& data);
signals:
    void dataReceivedFromSocket(quint16 localPort, const QHostAddress &senderIp, quint16 senderPort, const QByteArray &data);
    void sendDataFrom(const QString &ip, const quint16& port, const QByteArray& data);
public slots:
    void dealMsg();
private:
    QMap<int, QUdpSocket*> udp;
};

#endif // UDP_H
